import 'package:taonile/generated/json/base/json_field.dart';
import 'package:taonile/generated/json/product_detail_entity.g.dart';
import 'dart:convert';

@JsonSerializable()
class ProductDetailEntity {
  late int code = 0;
  late String msg;
  late ProductDetailData data = ProductDetailData();

  ProductDetailEntity();

  factory ProductDetailEntity.fromJson(Map<String, dynamic> json) =>
      $ProductDetailEntityFromJson(json);

  Map<String, dynamic> toJson() => $ProductDetailEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class ProductDetailData {
  late String id = '';
  @JSONField(name: "main_img")
  late String mainImg;
  late List<String> img = [];
  @JSONField(name: "sales_num")
  late String salesNum = '';
  late String name = '';
  @JSONField(name: "store_id")
  late String storeId = '';
  @JSONField(name: "area_id")
  late String areaId = '';
  late String integral;
  late String price;
  late String tag = '1';
  late String detail='';

  @JSONField(name: "store_express_money")
  late String storeExpressMoney = '0';

  late ProductDetailDataStore store;
  late String money = '0';
  late String money1 = '0';
  late String company = '';
  late String company1 = '';
  @JSONField(name: "allow_pay_str")
  late String allowPayStr;
  late List<ProductDetailDataSku> sku = [];
  late List<ProductDetailDataSpec> spec = [];
  late String func;
  @JSONField(name: "is_save")
  late String isSave;

  ProductDetailData();

  factory ProductDetailData.fromJson(Map<String, dynamic> json) => $ProductDetailDataFromJson(json);

  Map<String, dynamic> toJson() => $ProductDetailDataToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class ProductDetailDataStore {
  late String id = "";
  late String name = "";
  late String logo = "";

  ProductDetailDataStore();

  factory ProductDetailDataStore.fromJson(Map<String, dynamic> json) =>
      $ProductDetailDataStoreFromJson(json);

  Map<String, dynamic> toJson() => $ProductDetailDataStoreToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class ProductDetailDataSku {
  late String id = "";
  @JSONField(name: "goods_id")
  late String goodsId = "";
  @JSONField(name: "spec_key")
  late List<String> specKey = [];
  @JSONField(name: "spec_val")
  late List<String> specVal = [];
  late String stock;
  @JSONField(name: "img_path")
  late String imgPath='';
  late String status;
  late String price;
  late String sales;
  @JSONField(name: "created_at")
  late String createdAt;
  @JSONField(name: "updated_at")
  late String updatedAt;
  late String integral;
  @JSONField(name: "allow_pay_str")
  late String allowPayStr;
  late String money = "0";
  late String money1 = "0";
  late String company = "";
  late String company1 = "";

  ProductDetailDataSku();

  factory ProductDetailDataSku.fromJson(Map<String, dynamic> json) =>
      $ProductDetailDataSkuFromJson(json);

  Map<String, dynamic> toJson() => $ProductDetailDataSkuToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class ProductDetailDataSpec {
  late String name;
  late List<String> items;

  ProductDetailDataSpec();

  factory ProductDetailDataSpec.fromJson(Map<String, dynamic> json) =>
      $ProductDetailDataSpecFromJson(json);

  Map<String, dynamic> toJson() => $ProductDetailDataSpecToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
